﻿/*
 * @Autor: PK
 * @Date: 2021/12/28 14:01:SS
 */

using System.Collections.Generic;
using ShkSimulation.core.exceptions;

namespace ShkSimulation.core.dao.statistic.feature {

	public class StatisticInfoBuilder {
        
        string VariableName { get; set; }
        
        string HourStatisticName { get; set; }
        
        public IDictionary<string,DataPair> Datas { get; set; }

        public StatisticInfoBuilder() {
            Datas = new Dictionary<string, DataPair>();
        }

        public StatisticInfo Build() {
            if (VariableName == null) {
                throw new ErrorParamException("VariableName不能为空");
            }            
            if (HourStatisticName == null) {
                throw new ErrorParamException("HourStatisticName不能为空");
            }
            StatisticInfo statisticInfo = new StatisticInfo(new VariableAndHourStatisticKey(VariableName, HourStatisticName));
            statisticInfo.Datas = new Dictionary<string, DataPair>(this.Datas);
            return statisticInfo;
        }
                
        public StatisticInfoBuilder SetStatisticDataValue(string statistic, double sumValue) {
            Datas.Add(statistic, new DataPair(statistic, sumValue));
            return this;
        }        

        public StatisticInfoBuilder SetVariableName(string variableName) {
            VariableName = variableName;
            return this;
        }
        
        public StatisticInfoBuilder SetHourStatisticName(string hourStatisticName) {
            HourStatisticName = hourStatisticName;
            return this;
        }

    }

}